<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>省 DPI 汇聚平台后台管理系统</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <link href="../assets/css/bootstrap.min.css" rel="stylesheet" />
        <link rel="stylesheet" href="../assets/css/font-awesome.min.css" />
        <link rel="stylesheet" href="../assets/css/ace.min.css" />
        <link rel="stylesheet" href="../assets/css/ace-rtl.min.css" />
        <link rel="stylesheet" href="../assets/css/ace-skins.min.css" />
        <script src="../assets/js/jquery.js"></script>

    </head>

    <body>
        <div class="main-container">
            <div class="page-content">
                <div class="row">
                    <div class="">
                        <div class="widget-box transparent">
                            <div class="widget-header widget-header-flat">
                                <h4 class="lighter">
                                    系统配置
                                </h4>
                            </div>

                            <div class="widget-body">
                                <div class="widget-main no-padding">
                                    
                                    <table class="table table-bordered table-striped">
                                        <thead class="thin-border-bottom">
                                            <tr>
                                                <th width="300">
                                                    <i class="icon-caret-right blue"></i>
                                                    键（key）
                                                </th>
                                                <th>
                                                    <i class="icon-caret-right blue"></i>
                                                    值（value）
                                                </th>
                                            </tr>
                                        </thead>
                                        <tbody id="confgTable">
                                            <tr>
                                                <td>策略服务设置</td>
                                                <td>
                                                    <input type="text" class="input-xlarge config-txt" id="PolicyRepoServer_webserver_url" name="" key="PolicyRepoServer.webserver.url" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>服务端口</td>
                                                <td>
                                                    <input type="text" class="input-xlarge config-txt" id="server_port" name="" key="server.port" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>服务限制值</td>
                                                <td>
                                                    <input type="text" class="input-xlarge config-txt" id="server_throttle" name="" key="server.throttle" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>SFTP文件生成路径</td>
                                                <td>
                                                    <input type="text" class="input-xlarge config-txt" id="common_file_path" name="" key="common.file.path" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>Web类流量统计URL设置</td>
                                                <td>
                                                    <input type="text" class="input-xlarge config-txt" id="report_web_flow_statistics" name="" key="report.web.flow.statistics" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>VoIP类流量统计URL设置</td>
                                                <td>
                                                    <input type="text" class="input-xlarge config-txt" id="report_voip_flow_statistics" name="" key="report.voip.flow.statistics" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>通用类流量统计URL设置</td>
                                                <td>
                                                    <input type="text" class="input-xlarge config-txt" id="report_general_flow_statistics" name="" key="report.general.flow.statistics" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>访问指定应用的用户统计URL设置</td>
                                                <td>
                                                    <input type="text" class="input-xlarge config-txt" id="report_visit_app_statistics" name="" key="report.visit.app.statistics" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>非法路由检测分析URL设置</td>
                                                <td>
                                                    <input type="text" class="input-xlarge config-txt" id="report_illegal_route_analysis" name="" key="report.illegal.route.analysis" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>一拖 N 用户行为分析（关键字段）URL设置</td>
                                                <td>
                                                    <input type="text" class="input-xlarge config-txt" id="report_share_detect_analysis" name="" key="report.share.detect.analysis" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>应用层 DDoS 异常流量分析功能模块URL设置</td>
                                                <td>
                                                    <input type="text" class="input-xlarge config-txt" id="report_ddos_app_attack" name="" key="report.ddos.app.attack" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>CP/SP 资源服务器分析模块URL设置</td>
                                                <td>
                                                    <input type="text" class="input-xlarge config-txt" id="report_cp_sp_resource_analysis" name="" key="report.cp.sp.resource.analysis" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>流量流向分析结果上报URL设置</td>
                                                <td>
                                                    <input type="text" class="input-xlarge config-txt" id="report_flow_direction_analysis" name="" key="report.flow.direction.analysis" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>Web信息推送结果上报URL设置</td>
                                                <td>
                                                    <input type="text" class="input-xlarge config-txt" id="report_web_msg_send_result_report" name="" key="report.web.msg.send.result.report" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>UD日志查询URL设置</td>
                                                <td>
                                                    <input type="text" class="input-xlarge config-txt" id="report_udlog_browse" name="" key="report.udlog.browse" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>移动终端类型上报设置</td>
                                                <td>
                                                    <input type="text" class="input-xlarge config-txt" id="report_wlanreport" name="" key="report.wlanreport" />
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                                <div style="margin: 10px;">
                                    <button type="button" class="btn btn-sm bnt-danger" onclick="undo();">取消</button>
                                    <button type="button" class="btn btn-sm btn-primary" onclick="save();">保存</button>
                                </div>
                            </div> 
                        </div> 
                    </div>
                </div>

            </div>
        </div>

        <script src="../assets/js/bootstrap.min.js"></script>
        <script src="../assets/js/ace-extra.min.js"></script>
        <script src="../assets/js/ace-elements.min.js"></script>
        <script src="../assets/js/ace.min.js"></script>
        <script>
            function undo(){
                window.location.reload();
            }
            function save(){
                var count = 0;
                var config = $("#confgTable").find(".config-txt");
                var config_arr = [];
                config.each(function(i,obj){
                   var property = $(obj).attr("key");
                   var value = $(obj).val();
                   var tmp = {};
                   tmp[property] = value;
                   config_arr.push(tmp);
//                     $.ajax({ 
//                        type: "post", 
//                        url: "/WebManage/action/system/setproperty.do",
//                        cache:false, 
//                        async:false, 
//                        dataType:"json" ,
//                        data:{property:property,value:value},
//                        success: function(data){ 
////                            data = JSON.parse(data);
//                            if (data.result == "true") {
//                                count++;
//                            } 
//                        } 
//                    });
                    
                });
                
                $.ajax({ 
                    type: "post", 
                    url: "/WebManage/action/system/setlistproperty.do",
                    cache:false, 
                    async:false, 
                    dataType:"json" ,
                    data:{property:JSON.stringify(config_arr)},
                    success: function(data){ 
//                            data = JSON.parse(data);
                        if (data.result == "true") {
                            alert("保存成功！");
                        } else{
                            alert("保存失败！");
                        }
                    } 
                });
                
//                if(count == 16){
//                    alert("保存成功！");
//                }else{
//                    alert("保存失败！");
//                }
//                console.log(count);
            }
            
            $(function(){
                
                setInterval(function () {
                    parent.$("#page-content").attr("height", $("html").height());
                }, 500);
                
                var inputs = $("#confgTable").find(".config-txt");
                var prop_arr = [];
                inputs.each(function(index,item){
                    var property = $(item).attr("key");
                    prop_arr.push(property);
//                    $.post("/WebManage/action/system/getproperty.do",{property:property},function(data){
//                        $(item).val(data);
//                    }) ;
//                     $.ajax({ 
//                        type: "post", 
//                        url: "/WebManage/action/system/getproperty.do",
//                        cache:false, 
//                        async:false, 
//                        dataType:"json" ,
//                        data:{property:property},
//                        success: function(data){ 
//                            $(item).val(data);
//                        } 
//                    });
                   
                });
                
                $.post("/WebManage/action/system/getlistproperty.do",{property:JSON.stringify(prop_arr)},function(data){
                    var dataSrc = JSON.parse(data);
                    $.each(prop_arr,function(i,e){
                        var ne = e.replace(/[.]/g,"_");
                        $("#"+ne).val(dataSrc[i][e]) ;
                    });
                    
                });
               
            });
            
        </script>

    </body>
</html>